// 节流防抖的实现(分析笔试答案时问到，总结差别，说出应用场景)(https://www.cnblogs.com/LuckyWinty/p/5949970.html#4564734)

// 防抖
function debounce(fn, time) {
    let timer = null
    return function (...args) {
        clearTimeout(timer)
        timer = setTimeout(() => {
            fn.call(this, ...args)
        }, time)
    }
}

// 截流
function throtte(fn,time) {
    let timer = null
    return function (...args) {
        if (!timer) {
            fn.call(this, ...args)
            timer = setTimeout(() => {     
                timer = null;
            }, time)
        };
    }
}